extends Node2D

@onready var enemy=preload("res://场景/角色/敌人/敌人.tscn")
@onready var timer=$Timer
var tileMap=null
var level=1

func _ready() -> void:
	tileMap= get_parent().get_node('TileMap')
	pass

func _on_timer_timeout() -> void:
	var rand=RandomNumberGenerator.new()
	# 获取随机格子下标
	var cells=tileMap.get_used_cells(0)
	var num=rand.randi_range(0,len(cells)-1)
	# 将随机格子，世界坐标转换为本地
	var localPos=tileMap.map_to_local(cells[num])
	var enemyOne=enemy.instantiate()
	enemyOne.level=level
	enemyOne.copy=true
	enemyOne.position=localPos*tileMap.scale
	add_child(enemyOne)

# 回合结束增强敌人
func _on_round_end(rounds) -> void:
	level+=rounds
	timer.wait_time-=rounds/10
	pass 
